export default {
    state: {
        isselect: false, //是否刷新
        ListAllData: [{
            id: 0,
            img: 1,
            name: "衡州亩均（备份）",
            synopsis: "备注：亩均",
            time: "2020-02-02 16:01:01",
            nodeList: [{
                    type: "start",
                    typeName: "输入",
                    nodeName: "输入",
                    id: "34v56ha2l9c000",
                    top: "160px",
                    left: "100px"
                }, {
                    type: "dataSet",
                    typeName: "多表关联",
                    nodeName: "多表关联",
                    id: "5sdjugrcqhc000",
                    top: "160px",
                    left: "315px"
                },
                {
                    type: "encode",
                    typeName: "分组汇总",
                    nodeName: "分组汇总",
                    id: "3atqi5p6oa4000",
                    top: "80px",
                    left: "600px"
                },
                {
                    type: "personService",
                    typeName: "数据筛选",
                    nodeName: "数据筛选",
                    id: "49vcu89p5q0000",
                    top: "245px",
                    left: "600px"
                },
                {
                    type: "arrange",
                    typeName: "字段设置",
                    nodeName: "字段设置",
                    id: "1jhiilb0t2tc00",
                    top: "180px",
                    left: "880px"
                },
                {
                    type: "end",
                    typeName: "输出",
                    nodeName: "输出",
                    id: "1ogr3wzy6zhc00",
                    top: "180px",
                    left: "1160px"
                }
            ],
            nodeListBase: [],
            lineList: [{
                from: "34v56ha2l9c000",
                to: "5sdjugrcqhc000",
                label: "连线名称",
                id: "5n6pp5xqd6s000",
                Remark: ""
            }, ],
            history: [{
                    name: "输出",
                    active: "新增"
                },
                {
                    name: "字段设置",
                    active: "新增"
                },
                {
                    name: "数据筛选",
                    active: "新增"
                },
                {
                    name: "多表关联",
                    active: "新增"
                },
                {
                    name: "文件",
                    active: "新增"
                },
                {
                    name: "输入",
                    active: "新增"
                },
            ]
        }],
        nodeList: [{

        }],
        ListData: [],
        selectionList: [], // 当前选择的结果
        dataCount: 0, // 总条数
        pageSize: 10, // 每页显示多少条
        pageCurrent: 1, // 当前显示第几页
        pageShowsizer: true,
        pageShowTotal: true,
        pageShowElevator: true,
        pageSizeOpts: [5, 10, 20, 30, 40],
        modelData: {},
        CalculationProcessValue: "",
        datashaixaunModelmodel1: "",
        datashaixaunModelmodel2: "",
        datashaixaunModelmodel3: "",
        qieOrHuomodel: "",
        datashaixaunModelmodel4: "",
        datashaixaunModelmodel5: "",
        datashaixaunModelmodel6: "",
        datashaixaunModelmodel7: "",
        jisuanguochengArr: [], //id value 
    },
    getters: {

    },
    actions: {
        addDataCenter({
            commit,
            state
        }, data) {
            console.log("__data__", data);
            return new Promise((reslove) => {
                state.ListAllData.push({
                    id: state.ListAllData.length,
                    img: data.img,
                    name: data.name,
                    synopsis: data.synopsis,
                    time: data.time,
                    nodeList: [],
                    lineList: [],
                    history: [],
                })
                reslove({
                    code: 2000,
                    msg: "新增成功!"
                })
            })
        },
        deleteCalculationProcessArr({
            commit,
            state
        }, id) {
            return new Promise((reslove) => {
                if (state.jisuanguochengArr.length > 0) {
                    let idfindIndex = state.jisuanguochengArr.findIndex((arr) => {
                        return arr.id == id;
                    })
                    state.jisuanguochengArr.splice(idfindIndex, 1)
                }

                reslove({
                    code: 2000,
                    msg: "删除!"
                })
            })
        },
        getCalculationProcessData({
            commit,
            state
        }, {id}){
            return new Promise((reslove) => {
                let data ={
                    id:0,
                    value:"",
                };
                if (state.jisuanguochengArr.length > 0) {
                    let idfindIndex = state.jisuanguochengArr.findIndex((arr) => {
                        return arr.id == id;
                    })
                    data =  state.jisuanguochengArr[idfindIndex]
                    
                }

                reslove({
                    code: 2000,
                    msg: "查看",
                    data:data
                })
            })
        },
        addCalculationProcessArr({
            commit,
            state
        }, {
            id,
            value
        }) {
            return new Promise((reslove) => {
                if (state.jisuanguochengArr.length > 0) {
                    let idfindIndex = state.jisuanguochengArr.findIndex((arr) => {
                        return arr.id == id;
                    })
                    console.log("__idfindIndex__", idfindIndex)
                    if (idfindIndex == -1) {
                        state.jisuanguochengArr.push({
                            id: id,
                            value: value,
                        })
                    } else {
                        state.jisuanguochengArr.splice(idfindIndex, 1);
                        state.jisuanguochengArr.push({
                            id: id,
                            value: value,
                        })
                    }
                } else {
                    state.jisuanguochengArr.push({
                        id: id,
                        value: value,
                    })
                }
                reslove({
                    code: 2000,
                    msg: "新增成功"
                })
            })
        },


    },
    mutations: {
        setDataFactory(
            state, {
                isselect,
                ListAllData,
                ListData,
                dataCount,
                pageSize,
                pageCurrent,
                modelData
            },
        ) {
            if (modelData != undefined)
                state.modelData = modelData;
            if (isselect != undefined)
                state.isselect = isselect;
            if (ListAllData != undefined)
                state.ListAllData = ListAllData;
            if (ListData != undefined)
                state.ListData = ListData;
            if (dataCount != undefined)
                state.dataCount = dataCount;
            if (pageSize != undefined)
                state.pageSize = pageSize;
            if (pageCurrent != undefined)
                state.pageCurrent = pageCurrent;

        }
    }

}